package com.rgs.base.core.dto;

import com.rgs.base.core.page.IPageRequestModel;
import com.rgs.base.core.statics.CaseFormatStaticClass;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.time.LocalDate;

/**
 * @author Ren Gaoshuai
 * @ClassName CommonDateTimeListPageRequestDTO
 * @Description 通用带日期段的分页查询
 * @date 2021-12-17 9:22
 **/
@ToString
@ApiModel(description = "通用带日期段的分页查询")
@NoArgsConstructor
@AllArgsConstructor
@Data
public class CommonDateListPageRequestDTO implements IPageRequestModel {

    @ApiModelProperty(value = "单页行数", example = "50", required = true)
    @Min(1)
    protected Integer perPage;
    @ApiModelProperty(value = "当前页数", example = "1", required = true)
    @Min(1)
    protected Integer page;
    @ApiModelProperty(value = "排序字段", required = true)
    @NotBlank(message = "不能为空")
    protected String orderBy;

    @ApiModelProperty(value = "开始日期", example = "2020-01-22")
    private LocalDate beginDate;

    @ApiModelProperty(value = "结束日期", example = "2020-03-22")
    private LocalDate endDate;

    @Override
    public void setOrderBy(String orderBy) {
        this.orderBy = CaseFormatStaticClass.CAMEL_TO_UNDERSCORE.convert(orderBy);
    }
}
